package com.hzit.mmcb.core;

import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者：李嘉浩
 * 时间：2024-08-27-11:55
 * 功能：
 */

@SpringBootApplication(scanBasePackages = {"com.hzit.mmcb.core","com.hzit.mmb.base","com.hzit.common"})
public class MMChzbapplication {
    public static void main(String[] args) {
        SpringApplication.run(MMChzbapplication.class);
        initFlowQpsRule();
    }

    private static void initFlowQpsRule() {
        List<FlowRule> rules=new ArrayList<>();
        FlowRule rule = new FlowRule("lendList");
        rule.setCount(2);
        rule.setGrade(RuleConstant.FLOW_GRADE_QPS);
        rule.setLimitApp("default");
        rules.add(rule);
        FlowRuleManager.loadRules(rules);
    }
}
